package edu.humc.dao;

import edu.humc.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository("UserMapper")
public interface UserMapper {

    @Select("select * from user where username=#{username} and password=#{password}")
    User SelectUser(User user);
    @Select("select id from user where username=#{username} and password=#{password}")
    int SelectUserID(User user);
    @Insert("insert into user values(null,#{username},#{password},null,null,#{email},null,null)")
    int InsertUser(User user);
    @Update("update user set password=#{password} where username=#{username} and id=#{id}")
    int UpdateUser(User user);
    @Delete("delete from user where id=#{id}")
    int DeleteUser(int id);

//   根据用户id查用户用户名，（查询信息时间调用）
    @Select("select username from user where id=#{id}")
    String SelectUsernameByid(int id);
//根据用户id查用户
    @Select("select * from user where id=#{id}")
    User SelectUserByid(int id);
//更新用户信息
//    @Update("update user set realname=#{realname},birthdate=#{birthdate},phone=#{phone},imagepath=#{image_path} where id=#{id}")
@Update("update user set realname=#{realname},birthdate=#{birthdate},phone=#{phone} where id=#{id}")
    int UpdatePersonMessage(User user);

}
